import requests
import execjs

headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
}
cookies = {
    "sessionid": "f94jzt0egz3k9b4wnb6zceoieh70e7vk"
}
url = "https://match.yuanrenxue.cn/api/match/16"
# 加载js文件
with open(r'E:\Python\vscode\Crawlers\yuanrenxue\no16\task16_a.js','r') as f:
    js = execjs.compile(f.read())
# 调用里面的函数,没有参数，保存返回值
result_datas=[]
for i in range(1,6):
    p_key = js.call('mkey')
    params = {
        "page": i,
        "m": p_key['m'],
        "t": p_key['t']
    }
    response = requests.get(url, headers=headers, cookies=cookies, params=params)
    datas = response.json()['data']
    for i in datas:
        result_datas.append(i['value'])

print(sum(result_datas))